package com.adou.d17;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

public class Dom4jTest2 {
    public static void main(String[] args) {
        // 使用sb拼接xml
        StringBuilder sb = new StringBuilder();
        sb.append("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
        sb.append("<book>\r\n");
        sb.append("\t<name>").append("Java从入门到精通").append("</name>\r\n");
        sb.append("\t<author>").append("dlel").append("</author>\r\n");
        sb.append("\t<price>").append("999.99").append("</price>\r\n");
        sb.append("</book>");

        try(final BufferedWriter writer = new BufferedWriter(new FileWriter("d1-helloword-app\\src\\book.xml"));) {
            writer.write(sb.toString());
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
